package com.xzit.rcpyxt.controller;

import com.alibaba.fastjson.JSONObject;
import com.xzit.rcpyxt.constant.MessageCode;
import com.xzit.rcpyxt.dto.BindUserDto;
import com.xzit.rcpyxt.dto.ResultModel;
import com.xzit.rcpyxt.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/bind")
public class BindController {

    @Autowired
    private TeacherService teacherService;

    /**
     * 绑定用户
     * @param bindUserDto
     * @return
     */
    @RequestMapping(value = "/userBind", method = RequestMethod.POST)
    public ResultModel userBind (@RequestBody BindUserDto bindUserDto) {
        JSONObject jsonObject = teacherService.bindUserInfo(bindUserDto);
        return new ResultModel(MessageCode.OK, jsonObject);
    }

    /**
     * 校验是否绑定
     * @param bindUserDto
     * @return
     */
    @RequestMapping(value = "/checkUserBind", method = RequestMethod.POST)
    public ResultModel checkUserBind (@RequestBody BindUserDto bindUserDto) {
        JSONObject jsonObject = teacherService.checkUserIsBing(bindUserDto);
        return new ResultModel(MessageCode.OK, jsonObject);
    }

}
